package com.wyp168.leetcode;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName SubsetsSolution
 * @Title TODO
 * @Description TODO
 * @Author wyp168
 * @Date 2022/10/26 08:32
 */
public class SubsetsSolution {
    public static void main(String[] args) {
        SubsetsSolution solution = new SubsetsSolution();
        int[] nums = {1,2,3};
        for (List<Integer> subset : solution.subsets(nums)) {
            System.out.println(subset);
        }
    }

    public List<List<Integer>> subsets(int[] nums) {
        List<List<Integer>> resultList = new ArrayList<>();
        for (int i = 0; i < nums.length; i++) {
            dfs(nums, i, resultList);
        }
        resultList.add(new ArrayList<>());
        return resultList;
    }

    public void dfs(int[] nums, int begin, List<List<Integer>> resultList) {
        List<Integer> tempList = new ArrayList<>();
        while (begin < nums.length) {
            tempList.add(nums[begin ++]);
            resultList.add(new ArrayList<>(tempList));
        }
    }
}
